package br.com.kapa.beans;

import javax.ejb.Stateless;
import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.jws.WebService;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;

import br.com.kapa.model.Cliente;

/**
 * Session Bean implementation class ClienteBean
 */
@WebService(endpointInterface = "br.com.kapa.beans.ClienteEndpoint")
@Stateless(mappedName="bean/cliente")

public class ClienteBean implements ClienteBeanRemote {

	@PersistenceContext(unitName="industriaEJB") protected EntityManager em;
	
	
	@WebMethod(operationName="ConsultaCliente")
	public Cliente getCliente(@WebParam(partName="CPF")String cpf) {
		Query q = em.createQuery("SELECT c FROM Cliente c where c.cpfcnpj = '"+cpf+"'");
		Cliente cliente = (Cliente)q.getSingleResult();
		return cliente;
	}
	
	@WebMethod(operationName="helloworld")
	public String hello() {

		return "O webservice esta funcionando!";
	}


}
